window.addEventListener("load", function() {
    let form = document.getElementById("myform")
    // 重置表单
    form.reset();
})
let btn_submit = document.querySelector('#submit');
btn_submit.addEventListener("click", function () {

})
function $(elementId){
    return document.getElementById(elementId).value;
}
function checkUsername(){
    var username=$("username");
    var reg=/^[a-zA-Z][a-zA-Z0-9]{3,15}$/;
    if(reg.test(username)==false){
        alert("账号格式不正确!");
        document.getElementById("username").value="";
        return false;
    }
    return true;
}
/*验证邮箱*/
function checkEmail(){
    var userEmail=$("userEmail");
    var reg= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(reg.test(userEmail)==false){
        alert("邮箱格式不正确，例如wxl@qq.com!");
        document.getElementById("userEmail").value="";
        return false;
    }
    return true;
}
/*密码验证*/
function checkPassword(){
    var password=$("password");
    var again_password=$("again_password");
    var reg=/^[a-zA-Z0-9]{4,10}$/;
    if(reg.test(password)==false){
        alert("密码不能含有非法字符，长度在4-10之间!");
        document.getElementById("password").value="";
        return false;
    }
    if (password!=null){
        again_password.placeholder="221";
    }
    return true;
}

/*确认密码验证*/
function checkPasswordAgain(){
    var again_password=$("again_password");
    var password=$("password");
    if (again_password!=password) {
        alert("确认密码需要与密码相同！")
        document.getElementById("again_password").value="";
        return false;
    }
    return true;
}
